<div id="add-form" class="form-horizontal" role="form" data-toggle="validator" >
    <div class="content">
        <div class="panel panel-default panel-intro">

            <div class="panel-body">
                <div id="myTabContent" class="tab-content">
                    <div class="tab-pane fade active in" id="one">
                        <div class="widget-body no-padding">
                            <div class="bootstrap-table">
                                <div class="commonsearch-table ">
                                    <fieldset>
                                        <div class="row">

                                            <div class="form-group col-xs-12 col-sm-6 col-md-4 col-lg-3">
                                                <label for="createtime" class="control-label col-xs-4">录单时间</label>
                                                <div class="col-xs-8">
                                                    <input type="text" class="form-control datetimepicker" name="createtime" value="{:date('Y-m-d',$row['createtime'])}" placeholder="录单时间" id="createtime" data-index="2">
                                                </div>
                                            </div>

                                            <div class="form-group col-xs-12 col-sm-6 col-md-4 col-lg-3">
                                                <label for="operator" class="control-label col-xs-4">供货商</label>
                                                <div class="col-xs-8">
                                                    <input id="c-supplier_id" class="form-control" data-rule="required"  name="supplier_id" type="text" value="{$snick}" >

                                                </div>
                                            </div>
                                            <div class="form-group col-xs-12 col-sm-6 col-md-4 col-lg-3">
                                                <label for="operator" class="control-label col-xs-4">经手人</label>
                                                <div class="col-xs-8">
                                                    <input type="text" class="form-control" name="operator" value="{$row['operator']}" placeholder="经手人" id="operator" data-index="6" >
                                                </div>
                                            </div>
                                            <div class="form-group col-xs-12 col-sm-6 col-md-4 col-lg-3">
                                                <label for="company" class="control-label col-xs-4">部门单位</label>
                                                <div class="col-xs-8">
                                                    <input type="text" class="form-control" name="company" value="{$row['operator']}" placeholder="部门单位" id="company" data-index="7" >
                                                </div>
                                            </div>
                                            <div class="form-group col-xs-12 col-sm-6 col-md-4 col-lg-3">
                                                <label for="company" class="control-label col-xs-4">税点</label>
                                                <div class="col-xs-8">
                                                    <input type="number" class="form-control " name="tax" value="{$row['tax']}" placeholder="税费" id="shuifei" data-index="7">
                                                </div>
                                            </div>
                                            <div class="form-group col-xs-12 col-sm-6 col-md-4 col-lg-3"><label for="storehouse_id" class="control-label col-xs-4">入库仓库</label>
                                                <div class="col-xs-8">
                                                    <input id="c-store" data-rule="required" class="form-control"  name="storehouse_id" type="text" value="{$hname}">
                                                </div>
                                            </div>
                                            <div class="form-group col-xs-12 col-sm-6 col-md-4 col-lg-3">
                                                <label for="explain" class="control-label col-xs-4">说明</label>
                                                <div class="col-xs-8">
                                                    <input type="text" class="form-control" name="explain" value="{$row['explain']}" placeholder="说明" id="explain" data-index="13">
                                                </div>
                                            </div>
<!--                                            <div class="form-group col-xs-12 col-sm-6 col-md-4 col-lg-3">-->
<!--                                                <label for="abstract" class="control-label col-xs-4">摘要</label>-->
<!--                                                <div class="col-xs-8">-->
<!--                                                    <input type="text" class="form-control" name="abstract" value="{$row['abstract']}" placeholder="摘要" id="abstract" data-index="14">-->
<!--                                                </div>-->
<!--                                            </div>-->
                                        </div>
                                    </fieldset>
                                </div>
                            </div>
                            </div>
                                <table id="table" class="table table-striped table-bordered table-hover table-nowrap" style="display: block;overflow:auto;" data-operate-edit="1" data-operate-del="1" width="auto">
                                    <thead>
                                    <tr>
<!--                                        <th class="bs-checkbox " style="text-align: center; vertical-align: middle; width: 36px; " data-field="0">-->
<!--                                            <div class="th-inner ">-->
<!--                                                <input name="btSelectAll" type="checkbox">-->
<!--                                            </div>-->
<!--                                        </th>-->
                                        <th style="text-align: center; vertical-align: middle; " data-field="id">
                                            <div class="th-inner ">Id</div>
                                            <div class="fht-cell">

                                            </div>
                                        </th>
                                        <th style="text-align: center; vertical-align: middle; " data-field="createtime">
                                            <div class="th-inner ">商品编号</div>
                                        </th>
                                        <th style="text-align: center; vertical-align: middle; " data-field="number"><div class="th-inner ">商品名称</div>
                                        </th>
                                        <th style="text-align: center; vertical-align: middle; " data-field="status">
                                            <div class="th-inner ">产地</div>
                                        </th>
                                        <th style="text-align: center; vertical-align: middle; " data-field="supplier_id">
                                            <div class="th-inner ">规格</div>
                                        </th>
                                        <th style="text-align: center; vertical-align: middle; " data-field="operator">
                                            <div class="th-inner ">账面库存</div>
                                        </th>
                                        <th style="text-align: center; vertical-align: middle; " data-field="company">
                                            <div class="th-inner ">虚拟库存
                                            </div>
                                        </th>
                                        <th style="text-align: center; vertical-align: middle; " data-field="order_goods_total"><div class="th-inner ">采购数量</div><div class="fht-cell"></div></th>
                                        <th style="text-align: center; vertical-align: middle; " data-field="arrival_total"><div class="th-inner ">采购单位</div><div class="fht-cell"></div></th>
                                        <th style="text-align: center; vertical-align: middle; " data-field="order_price"><div class="th-inner ">采购单价</div><div class="fht-cell"></div></th>
                                        <th style="text-align: center; vertical-align: middle; " data-field="arrival_price"><div class="th-inner ">税点</div><div class="fht-cell"></div></th>
                                        <th style="text-align: center; vertical-align: middle; " data-field="order_price"><div class="th-inner ">采购金额</div><div class="fht-cell"></div></th>
                                        <th style="text-align: center; vertical-align: middle; " data-field="paid_in_price"><div class="th-inner ">含税单价</div><div class="fht-cell"></div></th>
                                        <th style="text-align: center; vertical-align: middle; " data-field="paid_in_price"><div class="th-inner ">税额</div><div class="fht-cell"></div></th>
<!--                                        <th style="text-align: center; vertical-align: middle; " data-field="explain"><div class="th-inner ">所有运费</div><div class="fht-cell"></div></th>-->
<!--                                        <th style="text-align: center; vertical-align: middle; " data-field="explain"><div class="th-inner ">单件运费</div><div class="fht-cell"></div></th>-->
                                        <th style="text-align: center; vertical-align: middle; " data-field="explain"><div class="th-inner ">税费合计</div><div class="fht-cell"></div></th>
<!--                                        <th style="text-align: center; vertical-align: middle; " data-field="explain"><div class="th-inner ">单件成本</div><div class="fht-cell"></div></th>-->
                                        <!--                                                <th style="text-align: center; vertical-align: middle; " data-field="abstract"><div class="th-inner ">已收获数量</div><div class="fht-cell"></div></th>-->
                                        <th style="text-align: center; vertical-align: middle; " data-field="operate"><div class="th-inner ">备注</div><div class="fht-cell"></div></th>
<!--                                        <th style="text-align: center; vertical-align: middle; " data-field="operate"><div class="th-inner ">操作</div><div class="fht-cell"></div></th>-->
                                    </tr>
                                    </thead>
                                    <tbody data-listidx="0" class="connnn">
                                            {volist name="list" id="vo"}
                                            <tr data-index="0">
                                                <td style="text-align: center; vertical-align: middle; ">{$vo.id}</td>
                                                <td style="text-align: center; vertical-align: middle; ">{$vo.number}</td>
                                                <td style="text-align: center; vertical-align: middle; ">{$vo.title}</td>
                                                <td style="text-align: center; vertical-align: middle; ">{$vo.place_origin}</td>
                                                <td style="text-align: center; vertical-align: middle; ">{$vo.specs}</td>
                                                <td style="text-align: center; vertical-align: middle; ">{$vo.stock}</td>
                                                <td style="text-align: center; vertical-align: middle; ">{$vo.xstock}</td>
                                                <td style="text-align: center; vertical-align: middle; " class="goods_num">{$vo.goods_num}</td>
                                                <td style="text-align: center; vertical-align: middle; ">{$vo.unit}</td>
                                                <td style="text-align: center; vertical-align: middle; ">{$vo.unit_price}</td>
                                                <td style="text-align: center; vertical-align: middle; ">{$vo.tax}</td>
                                                <td style="text-align: center; vertical-align: middle; " class="buy_price"> {$vo.buy_price}</td>
<!--                                                <td style="text-align: center; vertical-align: middle; " class="buy_price"> {$vo.goods_num*$vo.unit_price*(100+$vo.tax)/100}</td>-->

                                                <td style="text-align: center; vertical-align: middle; ">{$vo.ht_price}</td>
                                                <td style="text-align: center; vertical-align: middle; " class="tax_all">{$vo.tax_all}</td>
<!--                                                <td style="text-align: center; vertical-align: middle; " class="all_fare">{$vo.fare}</td>-->
<!--                                                <td style="text-align: center; vertical-align: middle; ">{$vo.fare/$vo.goods_num}</td>-->
                                                <td style="text-align: center; vertical-align: middle; " class="count">{$vo.ht_price*$vo.goods_num+$vo.fare}</td>
<!--                                                <td style="text-align: center; vertical-align: middle; ">{$vo.cost}</td>-->
                                                <td style="text-align: center; vertical-align: middle; ">{$vo.remark}</td>
                                               </tr>
                                            {/volist}
                                    </tbody>
                                    <tbody class="tbfoot" data-listidx="0" >
                                        <td style="text-align: center; vertical-align: middle; ">合计</td>
                                        <td style="text-align: center; vertical-align: middle; "></td>
                                        <td style="text-align: center; vertical-align: middle; "></td>
                                        <td style="text-align: center; vertical-align: middle; "></td>
                                        <td style="text-align: center; vertical-align: middle; "></td>
                                        <td style="text-align: center; vertical-align: middle; " class="zstock"></td>
                                        <td style="text-align: center; vertical-align: middle; " class="xstock"></td>
                                        <td style="text-align: center; vertical-align: middle; " class="allnum">0</td>
                                        <td style="text-align: center; vertical-align: middle; "></td>
                                        <td style="text-align: center; vertical-align: middle; " ></td>
                                        <td style="text-align: center; vertical-align: middle; " ></td>
                                        <td style="text-align: center; vertical-align: middle; " class="alprice">0</td>
                                        <td style="text-align: center; vertical-align: middle; "></td>
                                        <td style="text-align: center; vertical-align: middle; " class="alltax">0</td>
<!--                                        <td style="text-align: center; vertical-align: middle; " class="fare">0</td>-->
<!--                                        <td style="text-align: center; vertical-align: middle; " ></td>-->
                                        <td style="text-align: center; vertical-align: middle; " class="price_tax">0</td>
<!--                                        <td style="text-align: center; vertical-align: middle; "></td>-->
                                        <td style="text-align: center; vertical-align: middle; "></td>
                                    </tbody>
                                    </table>
                         </div>
<!--                                <br>-->
<!--                                <div class="widget-body no-padding">-->
<!--                                    <div class="bootstrap-table">-->
<!--                                        <div class="commonsearch-table ">-->
<!--                                            <fieldset>-->
<!--                                                <div class="row">-->
<!--                                                    <div class="form-group col-xs-12 col-sm-6 col-md-4 col-lg-3">-->
<!--                                                        <label for="company" class="control-label col-xs-4">优惠</label>-->
<!--                                                        <div class="col-xs-8">-->
<!--                                                            <input type="text" class="form-control " name="discount" value="{$row.discount}" placeholder="优惠" id="discount" data-index="7" onkeyup="checkInputIntFloat(this);">-->
<!--                                                        </div>-->
<!--                                                    </div>-->
<!--                                                    <div class="form-group col-xs-12 col-sm-6 col-md-4 col-lg-3">-->
<!--                                                        <label for="c-discount-explain" class="control-label col-xs-4">优惠说明</label>-->
<!--                                                        <div class="col-xs-8">-->
<!--                                                            <input id="c-discount-explain"   class="form-control " name="discount_explain" type="text" value="{$row.discount_explain}" >-->
<!--                                                        </div>-->
<!--                                                    </div>-->
<!--                                                    <div class="form-group col-xs-12 col-sm-6 col-md-4 col-lg-3">-->
<!--                                                        <label for="c-actual-cost" class="control-label col-xs-4">实际费用</label>-->
<!--                                                        <div class="col-xs-8">-->
<!--                                                            <input id="c-actual-cost" data-rule="required"  class="form-control actual_cost" name="actual-cost" type="text" value="{$row.actual_cost}" disabled>-->
<!--                                                            <input  data-rule="required"  class="form-control actual_cost" name="actual_cost" type="text" value="{$row.actual_cost}" style="display: none">-->
<!--                                                        </div>-->
<!--                                                    </div>-->
<!--                                                </div>-->

<!--                                        </fieldset>-->
<!--                                        </div>-->
<!--                                    </div>-->
<!--                                </div>-->
<!--                                 </div>-->
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<div class="form-group layer-footer">
    {if condition="$row['status'] == 2"}
    <div class="col-xs-12 col-sm-3">
        <button type="submit" class="btn btn-danger btn-embossed cancelbill {:$auth->check('purchase/order/cancelbill')?'':'hide'}">{:__('单据红冲')}</button>
    </div>
    {else /}
    {/if}
</div>
{if condition="$auth->check('purchase/order/examine') && $row.status == 1 "}
<div class="form-group layer-footer">
    <label class="control-label col-xs-12 col-sm-2"></label>
    <div class="col-xs-12 col-sm-8">
        <button type="submit" class="btn btn-success btn-embossed  subpurchase">{:__('审核通过')}
        </button>
        <button type="submit" class="btn btn-default btn-embossed  reject">{:__('驳回')}</button>
    </div>
</div>
{else /}

{/if}

<input type="hidden" value="{$row.id}" id="order_id">
<div class="form-group layer-footer">
<!--    <a class="btn btn-outline-success" href="javascript:f()" target="_self" style="margin-left: 20px">打印</a>-->
    <a class="btn btn-outline-success  printing" href="###" target="_self" style="margin-left: 20px" >打印</a>
</div>
<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js"></script>
<script>

    count()
    function count() {
        if($(".connnn > tr").length == 0){
            $('.tbfoot').attr('style','display:none')
            return false;
        }

        var alprice = 0;//采购金额
        var allnum = 0;//采购数量
        var alltax = 0;//税额
        var fare = 0;//税费合计
        var price_tax = 0;//运费


        $('.connnn').find("tr").each(function(){
           var goods_num = $(this).find('.goods_num').html()*1;
           var buy_price = $(this).find('.buy_price').html()*1;
           var tax_all = $(this).find('.tax_all').html()*1;
           var all_fare = $(this).find('.all_fare').html()*1;
           var count = $(this).find('.count').html()*1;
            allnum= allnum+goods_num
            alprice= buy_price+alprice
            alltax= alltax+tax_all
            fare= fare+all_fare
            price_tax= price_tax+count

        });
        $('.alprice').html(alprice.toFixed(4))
        $('.allnum').html(allnum)
        $('.alltax').html(alltax)
        $('.fare').html(fare)
        $('.price_tax').html(price_tax.toFixed(4))
    }
</script>
<script>

    // function printHTML(page)
    // {
    //     var bodyHTML=window.document.body.innerHTML;
    //     window.document.body.innerHTML=$(page).html();
    //     window.print();
    //     window.document.body.innerHTML=bodyHTML;
    // }

    // var oid = "{$row.id}"
    // // var url = Config.this_url+'/purchase/order/enter?ids='+oid
    // layer.confirm('是否通过该采购单？', {
    //     btn: ['确定','驳回'] //按钮
    // }, function(){
    //     var url = Config.this_url+'/purchase/order/examine?ids='+oid
    //     $.post(url,{status:1},function (res) {
    //         layer.msg(res.msg)
    //         if(res.code == 1){
    //             $('.btn-refresh').click()
    //         }
    //     })
    // }, function(){
    //     var url = Config.this_url+'/purchase/order/examine?ids='+oid
    //     $.post(url,{status:2},function (res) {
    //         layer.msg(res.msg)
    //         if(res.code == 1){
    //             $('.btn-refresh').click()
    //         }
    //     })
    // });
</script>
{include file='common/adapt' /}